home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Singles Flirt Up Your Life! (German)
/
Singles Flirt Up Your Life.iso
/
data1.cab
/
Statemachine
/
sofaBookChar.lua
< prev
next >
Wrap
Text File
|
2004-01-29
|
4KB
|
160 lines
-- sofa character state machine
beginStateMachine()
onEnter(function(msg)
-- local sofa = retrieveStateObject("seat");
local sofa = getStoredOrSender("seat", msg)
if (not sofa) then
-- sofa does not exist anymore
getParent().setEmoticon(EMOTICON_CANNOT, EMOTICON_DELAY);
sendMsg("emoThink", getParent().walkSO);
exitStateMachine();
else
storeStateObject("sofa", sofa);
end
--freeHands(getParent());
end )
onExit(function(msg)
-- local sofa = retrieveStateObject("sofa");
-- getParent().unlockActionPoints(sofa);
-- getParent().stopAllActivities(sofa);
-- removeStateObject("sofa");
unlockAll("sofa");
end )
-- sit down on sofa
state("sitDown")
onEnter(function(msg)
local sofa = retrieveStateObject("sofa");
local actionPointName = retrieveData("actionPointName");
if (getParent().isActionPointLocked(sofa, actionPointName)) then
-- action point is locked
getParent().setEmoticon(EMOTICON_CANNOT, EMOTICON_DELAY);
sendMsg("emoThink", getParent().walkSO);
freeHands(getParent());
exitStateMachine();
else
getParent().lockActionPoint(sofa, actionPointName);
setPose("sitdownArmchair");
sofa.playSound("Sofa setzen");
end
end )
onMsg("end", function(msg)
if testCancel() then
setState("standUp");
else
setState("readSitting");
end
end )
-- stand up from sofa
state("readSitting")
onEnter(function(msg)
-- remove closed book
getParent().detachLeftObjectHolder();
local book = retrieveStateObject("book");
if (book) then book.deleteGameObject(); end
-- load open book
book = getParent().loadGameObject("StandardGO","bookOpen");
if (not book) then
print("create bookOpen failed");
end
storeStateObject("book", book);
getParent().attachLeftObjectHolder(book);
local hands = getParent().handSO;
hands.stopAnimation();
startAnimation("readBookPage");
local sofa = retrieveStateObject("sofa");
getParent().startActivity("sit", sofa);
print(" read activity " .. retrieveData("bookType", " UNKONWN "));
local readBook = getParent().startActivity("read" .. retrieveData("bookType", "Novel"), book);
local length, scale = getActivityLength(readBook);
storeData("length", length);
sendDelayedMsgThis("complete", length);
sendDelayedMsgThis("turnPage", 3000);
this.actionComplete();
sendDelayedMsgThis("testCancel", CANCEL_POLLING_INTERVAL);
end )
onMsg("turnPage", function(msg)
startAnimation("readBookPage");
sendDelayedMsgThis("turnPage", random(5000, 20000));
end )
onMsg("end", function(msg)
if (testCancel()) then
setState("standUp");
end
end )
onMsg("queue", function(msg)
setState("standUp");
end )
onMsg("complete", function(msg)
setState("standUp");
end )
onMsg("testCancel", function(msg)
if testCancel() or (not this.getParent().getCurrentActivityGain()) then
setState("standUp");
else
sendDelayedMsgThis("testCancel", CANCEL_POLLING_INTERVAL);
end
end )
-- stand up from sofa
state("standUp")
onEnter(function(msg)
startAnimation("standupArmchair");
local sofa = retrieveStateObject("sofa");
getParent().stopAllActivities(sofa);
local hands = getParent().handSO;
hands.stopAnimation();
getParent().detachLeftObjectHolder();
local book = retrieveStateObject("book");
if (book) then
book.deleteGameObject();
getParent().stopAllActivities(book);
end
end )
onMsg("end", function(msg)
exitStateMachine();
end )
endStateMachine()